package bbs.utils;

import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

public class CopyTools {
    public static <T, S> List<T> copyList(List<S> paramS, Class<T> paramClass) {
        List<T> list = new ArrayList<T>();
        for (S s : paramS) {
            T t = null;
            try {
                t = paramClass.newInstance();
            }catch (Exception exception) {
                exception.printStackTrace();
            }
            BeanUtils.copyProperties(s, t);
            list.add(t);
        }
        return list;
    }
    public static <T, S> T copy(S paramS, Class<T> paramClass) {
        T t = null;
        try {
            t = paramClass.newInstance();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
        BeanUtils.copyProperties(paramS, t);
        return t;
    }
}
